public class StringDemo4 {
    /**
     * @author dengjiangming
     * @version 1.0.0
     * @date 2025-06-19
     */

    //分割字符串
    public static void main(String[] args) {
        String s = "name=zhangsan&age=10";
        //返回值是数组
        String[] strings = s.split("&");
        for (int i = 0; i < strings.length; i++) {
            System.out.println(strings[i]);
        }

        //一条华丽的分割线
        System.out.println("--------------------");

        //参数中有“|”字符，说明以‘&’或者‘|’分割

        strings = s.split("&|=");
        for (int i = 0; i < strings.length; i++) {
            System.out.println(strings[i]);
        }
    }
}
